package com.student.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.student.dao.StudentDao;
public class SinginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public SinginServlet() {
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		StudentDao studao = new StudentDao();
		// 学生签到，获取签到的学号
		request.setCharacterEncoding("utf-8");
		String stuNo = request.getParameter("stuNo");
		if(studao.isExist(stuNo)){
			//改变签到的状态
			studao.updateStudentStatusBySno(stuNo);
			
			
			
		}else{
			System.out.println("学生不存在..");
			response.sendRedirect("SinginServlet");
		}
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		PrintWriter out = response.getWriter();

		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
